package com.nuoniu.sibanyun.service.so.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.nuoniu.sibanyun.entity.so.VSaleInvoiceDetail;
import com.nuoniu.sibanyun.mapper.so.VSaleInvoiceDetailMapper;
import com.nuoniu.sibanyun.service.so.IVSaleInvoiceDetailService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 销售发票明细 服务实现类
 * </p>
 *
 * @author 小啊刚
 * @since 2020-12-07
 */
@Service
public class VSaleInvoiceDetailServiceImpl extends ServiceImpl<VSaleInvoiceDetailMapper, VSaleInvoiceDetail> implements IVSaleInvoiceDetailService {

    @Override
    public List<VSaleInvoiceDetail> getDetailsByOrderId(Long orderId) {
        UserInfo userInfo = UserThreadLocal.get();
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("company_id",userInfo.getCompanyId());
        queryWrapper.eq("order_id",orderId);
        List<VSaleInvoiceDetail> list = list(queryWrapper);
        return list;
    }

    @Override
    public void deleteByOrderId(Long orderId) {
        UserInfo userInfo = UserThreadLocal.get();
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("company_id",userInfo.getCompanyId());
        queryWrapper.eq("order_id",orderId);
        remove(queryWrapper);
    }
}
